﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.建造者模式
{
   public class Meal
    {
        private readonly List<IItem> items = new ();
        public void AddItem(IItem item)
        {
            items.Add(item);
        }

        public float GetCost()
        {
            float cost = 0.0f;
            foreach(var item in items)
            {
                cost += item.Price();
            }
            return cost;
        }

        public void ShowItems()
        {
            foreach(var item in items)
            {
                Console.WriteLine($"Item:{item.Name()}  Packing:{item.Packing().Pack()}  Price:{item.Price()}");
            }
        }
    }
}
